<?php
    include 'base.php';
    $username = $_POST['username'];
    $password = $_POST['password'];
    // 可以添加到数据库里
$sql1 = "SELECT * FROM `user` WHERE `username` = '$username'";
$res1 = $conn->query($sql1);
$row1 = mysqli_fetch_assoc($res1);
if(!is_null($row1)){
    echo json_encode(Array(
        'code'=>3,
        'msg'=>'已重复注册',
        'token' =>'',
        'err' =>0
    ));
}else{
    $sql = "INSERT INTO `user` (`username`, `password`) VALUES ('$username', '$password')";
        $res = $conn->query($sql);
        if($res){
            echo json_encode(Array(
                'code' => 0,
                'msg' => '注册成功',
                'token' => '12345343243vbvdbfnf',
                'err' => 1
            ));
        }else{
            echo json_encode(Array(
                'code' => 1,
                'msg' => '注册失败',
                'token' => '',
                'err' => 0
            ));
        }
    }  



?>